package com.cat.twoPointerTechnique;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/sum-of-square-numbers/
 * @create 2025/8/3 15:09
 * @since JDK17
 */

public class Solution09 {
    public boolean judgeSquareSum(int c) {
        if (Math.pow(Math.sqrt(c), 2) == c) {   // 不能被整除则
            return true;
        }
        int l = 1, r = ((int) Math.sqrt(c));
        while (l <= r) {
            int attempt = l * l + r * r;
            if (attempt > c) {
                r--;
            } else if (attempt < c) {
                l++;
            } else {
                return true;
            }
        }
        return false;
    }
}
